﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using KTX.Public;

namespace KTX.Data
{
    public class CanBoData
    {
        //load CanBo
        ClsKetNoi cls = new ClsKetNoi();
        public int Count()
        {
            throw new NotImplementedException();
        }
        public DataTable LoadCanBo()
        {
            return cls.LayDuLieu("select * from CAN_BO");
        }
        public DataTable TimtheoMaCanBo(CanBoPublic p)
        {            
            int NParameter = 1;
            string[] name = new string[NParameter];
            object[] value = new object[NParameter];
            name[0] = "@ma_cb";
            value[0] = p.CanBoMa;
            return cls.LayDuLieu("select * from can_bo where ma_cb = @ma_cb", name, value, NParameter);
        }
        public int Them(CanBoPublic p)
        {
            int NParameter = 3;
            string[] name = new string[NParameter];
            object[] value = new object[NParameter];
            name[0] = "@ma_cb";
            name[1] = "@hoten_cb";
            name[2] = "@chuc_vu";
            value[0] = p.CanBoMa;
            value[1] = p.CanBoTen;
            value[2] = p.CanBoChucVu;
            return cls.Update("insert into can_bo (ma_cb,hoten_cb,chuc_vu) values (@ma_cb,@hoten_cb,@chuc_vu)", name, value, NParameter); 
        }
        public int Xoa(CanBoPublic p)
        {
            int NParameter = 1;
            string[] name = new string[NParameter];
            object[] value = new object[NParameter];
            name[0] = "@ma_cb";
            value[0] = p.CanBoMa;
            return cls.Update("delete from can_bo where ma_cb = @ma_cb", name, value, NParameter);
        }

    }
}
